import java.util.Arrays;
import java.util.Scanner;
import java.util.Stack;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Gao zhao xu
 * Date: 2023-10-09
 * Time: 9:46
 */
public class test {
    public static boolean IsPopOrder (int[] pushV, int[] popV) {
        // write code here
        int l = pushV.length;
        Stack<Integer> stack = new Stack<>();
        int j = 0;
        int i = 1;
        stack.push(pushV[0]);
        while (j < l || i < l){
            if (stack.peek() != popV[j]){
                stack.push(pushV[i]);
                i++;
            }else{
                stack.pop();
                j++;
            }
        }
        if (stack.empty()){
            return true;
        }
        return false;
    }
    public static void main(String[] args) {
//        System.out.println("1.=================================");
//        Stack<Integer> stack = new Stack();
//        //压栈
//        stack.push(12);
//        stack.push(23);
//        stack.push(34);
//        stack.push(45);
//        System.out.println(stack);
//        System.out.println("2.=================================");
//        //出栈
//        stack.pop();
//        System.out.println(stack);
//        //由此可见先入后出
//        System.out.println("3.=================================");
//        //获取栈顶数据，但是不出栈
//        int a = stack.peek();
//        System.out.println(a);
//        System.out.println("4.=================================");
//        //获取栈数据个数
//        int size = stack.size();
//        System.out.println(size);
//        System.out.println("5.=================================");
//        //判断是否栈空
//        System.out.println(stack.empty());
//        System.out.println("6.=================================");
        int[] a = {1};
        int[] b = {2};
        System.out.println(IsPopOrder(a, b));
    }
}
